var xml = new XMLHttpRequest();
var rendererOptions = {
	draggable : true
};
var directionsDisplay = new google.maps.DirectionsRenderer(rendererOptions);
var directionsService = new google.maps.DirectionsService();
var geocoder;
var map;
var stepDisplay;
var markerArray = [];

function initialize() {
	initializeMap();
	var botao = document.getElementById("btn1");
	var botao2 = document.getElementById("btn2");

	botao.onclick = function() {
		var start = document.getElementById("origem").value;
		var end = document.getElementById("destino").value;
		calcRoute(start, end);
		botao2.onclick = CadastraCaronaServlet;
	};
}

function CadastraCaronaServlet() {
	xml.open("post", "CadastrarTrajeto");
	xml.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	var param;
	var start = document.getElementById("origem").value;
	var end = document.getElementById("destino").value;
	
//	var latlngStart = codeAddress(start);
//	var latlngEnd = codeAddress(end);
	
	param = simpleExtractPoints(resultGoogle);	
	
	xml.send("param=" + encodeURIComponent(param) + "&start="
			+ encodeURIComponent(start) + "&end=" + encodeURIComponent(end));
}

onload = initialize;
